package borge.web.teamspirit.client.page.team.panels;

import borge.web.teamspirit.client.SessionData;
import borge.web.teamspirit.client.interfaces.ServerCallbackHandler;
import borge.web.teamspirit.client.interfaces.WidgetEventHandler;
import borge.web.teamspirit.client.page.shared.widgets.ShowNewsWidget;
import borge.web.teamspirit.client.servercomm.DBQueryResults;

import com.google.gwt.user.client.ui.Label;

public class WelcomePanel extends MiddlePanel implements WidgetEventHandler, ServerCallbackHandler {
	
	private String welcomeText = "This is a welcome text. " +
			"This is a welcome text. " +
			"This is a welcome text. " +
			"This is a welcome text. ";
		
	
	private Label welcomeLabel;
	private ShowNewsWidget iNewsWidget;
	
	public WelcomePanel(){
		
		welcomeLabel = new Label(welcomeText);
		// we should have events, news, some text
		// perhaps events on the side actually..?
		
		add(welcomeLabel);

		iNewsWidget = new ShowNewsWidget(this);
		iNewsWidget.needsUpdate(SessionData.sCurrentTeam.getEncodedKey());
		iNewsWidget.requestServerData(this);
		
		add(iNewsWidget);
	}

	@Override
	public void handleWidgetEvent(WidgetEventType aEvent) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void forwardToken(String aWidget, String aData) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void handleServerCallback(DBQueryResults aResult, CallbackType aType) {
		// TODO Auto-generated method stub
		
		iNewsWidget.populateData(aResult);
		
	}

	@Override
	public void handleServerError(Throwable t) {
		// TODO Auto-generated method stub
		
	}

}
